<!DOCTYPE html>
<html >
<head>
	<div th:include="base-libs :: base-libs" ></div>
	<title>签约详情</title>
	<!-- <div th:include="common/fwb-modal :: fwb-modal" /> -->
	<style type="text/css">

		.form-table td {
			padding: 1px;
		}

		.form-table input, select {
			width: 100%!important;
		}
		.td-text{
			text-align: right;
			background: #f7f9fb;
			width: 90px;
			vertical-align: middle!important;
			color: #666;
		}
		.td-content{
			vertical-align: middle!important;
		}

		input, select{
			height: 28px!important;
			line-height: 28px!important;
			padding-left: 4px!important;
			box-sizing: border-box!important;
		}
		.panel{
			margin: 4px 2px;
		}
		.panel-header{
			padding: 10px 5px;
			background: #F2F2F2;
		}
		.panel-body{
			padding-bottom: 2px;
		}
		.panel-tool span{
			margin-right: 20px;
			font-weight: bold;
			cursor: pointer;
			color: #2AC672;
		}

		.rqflLi{
			display: inline-block;
			border: 1px solid #D4D4D4;
			vertical-align: middle;
			padding-right: 8px;
			margin-right: 35px;
			margin-bottom: 4px;
			margin-top: 4px;
			width: 170px;
		}

		.rqflLi label{
			display: inline-block;
			height: 30px;
			padding: 0px 6px;
			margin-right: 4px;
			text-align: center;
			background-color: #f7f9fb;
			border-right: 1px solid #D4D4D4;
		}
		.switchbutton{
			margin-bottom: 2px;
		}
		.switchbutton-on {
			background: #1ea15b;
			color: #fff;
		}

		.fwbLi{
			display: inline-block;
			border: 1px solid #D4D4D4;
			vertical-align: middle;
			padding-right: 8px;
			margin-right: 10px;
			margin-bottom: 4px;
			margin-top: 4px;
		}
		.fwbLi label{
			display: inline-block;
			height: 30px;
			padding: 0px 6px;
			margin-right: 4px;
			text-align: center;
			background-color: #f7f9fb;
			border-right: 1px solid #D4D4D4;
		}
		.fwbLi .fwbsx span{
			display: inline-block;
			height: 100%;
			cursor: pointer;
		}

		.fwbLi input{
			display: inline-block;
			width: 14px!important;
			height: 14px!important;
			vertical-align: middle;
			margin-bottom: 2px;
		}

		.jtcyCzDiv{
			vertical-align: middle;
			text-align: center;
			/* width: 80px; */
		}
		.jtcyCzDiv a{
			margin: auto 4px;
			line-height: 28px;
		}
		.panel,.panel-header,.panel-body{
		  	width:100% !important;
		}
	</style>

	<script th:src="'/service/js/jtqy.js'"></script>

	<script th:inline="javascript">
        /**读取request中的初始化数据*/
        var data = [[${data}]];
	</script>
	<script type="text/javascript">
		var JTQYINFO = StoreCache.removeCache("JTQYXQINFO");//家庭签约数据
		var BACKINFO = StoreCache.getCache("BACKINFO");//跳转页面
    	//var removeDetailBtn = StoreCache.removeCache("removeDetailBtn");
    	var removeDetailBtn = StoreCache.removeCache("fromQycx");//
        $(function() {
        	if(removeDetailBtn){
        		$("#btnJy").remove();
        		$("#btnXy").remove();
        		$("#btnZj").remove();
        		$("#btnBgfwb").remove();
        	}
        	initData();
        	//setHeight();
        });
		/*查询历史记录*/
        function findLsjl(){
            findQyxxLsjl(JTQYINFO.JMXXID);
        }

        function initData(){
        	//时间格式化
        	JTQYINFO.JSSJ = cutDate_YYYYMMDD(JTQYINFO.JSSJ);
        	JTQYINFO.SXSJ = cutDate_YYYYMMDD(JTQYINFO.SXSJ);
        	JTQYINFO.CSRQ = cutDate_YYYYMMDD(JTQYINFO.CSRQ);

        	$("body").data("qyxx",JTQYINFO);
        	$("#QYXXID").val(JTQYINFO.QYXXID);
        	var information = qyxxFormatData(JTQYINFO);
        	
            $(".form-control").each(function(){
                var name = $(this).attr("name");
                var value = information[name];
                if($(this).hasClass("isTitle")){
                	$(this).attr("title",value);
                }
                $(this).val(value);
            })
            var jtcy = data.JTCY;
		    if(!StringUtils.isEmpty(jtcy)){
		    	$.each(jtcy,function (index,obj){
		    		JtcyHandler(obj);
		    	})
		    }

		    /*查询医保服务项*/
		    $.QuickRemote.AjaxJson(contextRoot + "jtqy/queryYbfwx", function(result){
                var YBFWX_ARR = [];
                $.each(result, function(){
                    YBFWX_ARR.push(this.FWMC);
                })
                if(YBFWX_ARR.length>0){
                    $("#YBFWX").val(YBFWX_ARR.join()).parents("tr").show();
                }
			}, {QYXXID: JTQYINFO.QYXXID});
        }
        //解约
    	function qyxxJyCz(){
//    		parent.layer.confirm('您确定要解约这个人吗？' , {icon: 3, title:'提示'}, function(index){
//    			  parent.layer.close(index);
//    			  parent.layer.prompt({title: '请填写解约原因', formType: 2}, function(text, index){
//    			    if(StringUtils.isEmpty(text)){
//    			    	parent.layer.msg('请填写解约原因！');
//    			    	return;
//    			    }
//    			    qyxxJyFun(text);
//    			    parent.layer.close(index);
//    			  });
//			});

            JTQYINFO.FWBIDS = JTQYINFO.FWBID.split(",").join("|");
            StoreCache.setCache("xy_jfMsg",JTQYINFO);//协议_甲方信息
			StoreCache.setCache("czxxDivId","jyxxDiv");//czxxDivId(注：操作信息展示的Div的Id) 为： jyxxDiv
			parent.layer.open({
			    type: 2,
			    area: ["800px", "90%"],
			    content: contextRoot + 'jtqy/changeXy.html',
			    scrollbar: false,
			    resize: false,
			    title:'新协议确定',
			    end: function(){
					var xyContent = StoreCache.removeCache("xyContent");
			        if(!StringUtils.isEmpty(xyContent)){
			            //当前写法prompt默认为必填
                        parent.layer.prompt({title: '请填写解约原因', formType: 2, maxlength:200}, function(text, index){
                            qyxxJyFun(text,xyContent);
                            parent.layer.close(index);
                        });
			        }
			    }
			});
    	}
    	//解约更新
    	function qyxxJyFun(jyyy,xyContent){
    		
    		var param = {
    			QYXXIDS: JTQYINFO.QYXXID,
                JMXXIDS: JTQYINFO.JMXXID,
    			ZTMS:jyyy,
                CONTENT: xyContent,
                TDID: JTQYINFO.YLTDID,
                TDMC: JTQYINFO.TDMC,
				XYH: StoreCache.removeCache("XYH")
    		};
    		var jyurl = $.QuickUrlUtils.getProjectName()+"/jtqy/jyfw"
    		$.QuickRemote.AjaxJson(jyurl,function(result){
    			if (result["state"]) {
    			   $.QuickAlert.alertNormal("解约成功！",{callback: function(){
    				   btnBackHandler();
    				}});
    			} else {
    				$.QuickAlert.alertFail({
    					content : info["faultInfo"]
    				});
    			}
    		},param);
    	}
    	//变更服务包
    	function bgfwbCz(){
    		var jgqyxx = [JTQYINFO];
    		StoreCache.setCache("JTQYBGFWBINFO", jgqyxx);
    		parent.layer.open({
    			type : 2,
    			title : "变更服务包操作",
    			shadeClose : false,
    			shade : 0.8,
    			area : [ "85%", "55%" ],
    			content: contextRoot + 'model/bgfwbModel.html',
    			end: colseOpenBackHandler
    		});
    	}
    	
    	//续约
    	function qyxxXyCz(){
    		//console.log(JTQYINFO);
    		if(JTQYINFO.SFXY == "1"){
    			$.QuickAlert.alertFail({content : "该用户近期已有续约记录！"});
    		}else{
    			var back = {
    					SUCCESS: BACKINFO,
    					FAIL: "detail.html?to=detail&JMXXID=" + JTQYINFO.JMXXID 
    				};
    			StoreCache.setCache("XYBACKINFO", back);
    			StoreCache.setCache("JTQYXQINFO", JTQYINFO);
    			location = "xyManager.html?JMXXID=" + JTQYINFO.JMXXID + "&YLJGID=" + JTQYINFO.YLJGID + "&TDID=" + JTQYINFO.YLTDID;
    		}
    	}
    	
    	//转介
    	function zjtdCz(){
    		parent.layer.open({
    			type : 2,
    			title : "转介申请",
    			shadeClose : false,
    			shade : 0.8,
    			area : [ "320px", "335px" ],
    			content: contextRoot + 'model/zjModel.html?TDZT=1&YLTDID=' + JTQYINFO.YLTDID + '&RS=1&QYXXIDS=' + JTQYINFO.QYXXID
    					+ "&FWBIDS=" +JTQYINFO.FWBID,//iframe的url
    			end: colseOpenBackHandler
    		}); 
    	}
    	
    	function colseOpenBackHandler(){
    		var value = StoreCache.removeCache("JTQY_OPT_SUCCESS");
    		if(!StringUtils.isEmpty(value)){
    			btnBackHandler();
    		}
    	}
    	
    	/**返回回调*/
    	function btnBackHandler()
    	{
    		//$.QuickUrlUtils.redirectUrl(BACKINFO);
            StoreCache.removeCache("BACKINFO");
    		location = BACKINFO;
    	}

    	/** 时间截取  */
    	function cutDate_YYYYMMDD(date){
    		if(!StringUtils.isEmpty(date)){
    			return date.substring(0,10);
    		}else{
    			return date;
    		}
    	}

        /** 查看协议详情 */
        function queryXyDetail(index){
            var QYXXID = JTQYINFO.QYXXID;
            window.open(contextRoot + "jtqy/queryXyDetail.html?QYXXID="+ QYXXID, "_blank");
        }
	</script>
</head>
<body class="easyui-layout" >
	<div region="north" style="height: 41px; border: none; overflow: hidden; background-color: #f9f9f9;">
		<div class="title">
			<h3>签约详情</h3>
		</div>
	</div>
	<div region="center" style="overflow-x:hidden; border: none;">
			<div th:include="common/qyxqModelEasy :: qyxqModelEasy"></div>
	</div>
	<div region="south" style="height: 41px; border: none; background-color: #f9f9f9; padding-top: 6px; text-align: center;">
		<!-- <button id="btnSave" type="button" style=" margin-left: 10px;">协议确认</button>
		<button id="btnBack" type="button" style=" margin-left: 10px;">返回</button> -->
		<button id="btnDy" class="btn btn-info" type="button" onclick="queryXyDetail()">查看协议</button>
		<button id="btnJy" class="btn btn-info" type="button" onclick="qyxxJyCz()">解约</button>
		<button id="btnXy" class="btn btn-info" type="button" onclick="qyxxXyCz()">续约</button>
		<button id="btnZj" class="btn btn-info" type="button" onclick="zjtdCz()">转介</button>
		<button id="btnBgfwb" class="btn btn-info" type="button" onclick="bgfwbCz()">变更服务包</button>
		<button class="btn btn-info" type="button"
			 onclick="btnBackHandler()">返回</button>
	</div>
</body>
<script type="text/html" id="fwbLi">
	<li class="fwbLi">
		<label></label>
		<input class="easyui-switchbutton">
		<span class="fwbsx">
			<span><input type="radio" value="1">个人</span>
			<span><input type="radio" value="2">家庭</span>
		</span>
	</li>
</script>
<script type="text/html" id="cyxxTr">
	<tr class="cyxxTr">
		<td class="td-text">
			<label>身份证号：</label>
		</td>
		<td class="td-content" style="width: 160px;">
			<input type="text" autocomplete="off" name="SFZH" readonly="readonly" 
				   class="form-control">
		</td>
		<td class="td-text">
			<label>成员姓名：</label>
		</td>
		<td class="td-content" style="width: 120px;">
			<input type="text" autocomplete="off" name="XM" readonly="readonly" 
				   class="form-control">
		</td>
		<td class="td-text">
			<label>成员关系：</label>
		</td>
		<td class="td-content" style="width: 160px;">
			<input type="text" autocomplete="off" name="XMMC" readonly="readonly" 
				   class="form-control">
		</td>
		<td class="td-content" style="min-width: 210px;">
			<input type="text" readonly="readonly" name="QYXX" autocomplete="off"
				   class="form-control isTitle" onmouseover="this.title=this.value">
		</td>
		<td>
			<div class="jtcyCzDiv">
				<input name="RYSX" class="form-control" hidden="hidden" >
				<a class="jtcyBtn" action="remove">移除</a>
				<!-- <button class="btn btn-info jtcyBtn" type="button" action="remove">移除</button> -->
			</div>
		</td>
	</tr>
</script>
</html>
